package org.rcgwt.sample.client.grid;

import java.util.List;

import org.rcgwt.client.model.Reflected;
import org.rcgwt.client.ui.grid.PageButtonsPanel;
import org.rcgwt.client.ui.grid.RcGrid;
import org.rcgwt.client.ui.grid.RcGridConfig;
import org.rcgwt.client.ui.grid.reflect.EditableReflectedDataModel;
import org.rcgwt.client.ui.grid.theme.VistaGridTheme;
import org.rcgwt.sample.client.model.Employee;

import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * Base Example for Grid Use {@link Reflected} system for create Column
 * 
 * @author Matthieu ROBERT
 * 
 */
public class GridExample extends Widget implements EntryPoint {

	public void onModuleLoad() {

		Log.setUncaughtExceptionHandler();

		RcGridConfig config = new RcGridConfig();
		config.setTheme(VistaGridTheme.SINGLETON);
		config.setSelectable(true);
		EditableReflectedDataModel<Employee> model = new EditableReflectedDataModel<Employee>(
				Employee.class);
		config.setDataModel(model);
		config.setPageSize(8);

		List<Employee> employees = Employee.getEmployees(30);
		model.processRowInserted(0, employees);

		RcGrid grid = new RcGrid(config);

		RootPanel.get().add(grid);

		PageButtonsPanel panelPagination = new PageButtonsPanel(grid);
		RootPanel.get().add(panelPagination);

	}

}
